package cn.schoolwow.util.test.module.beanCopy.testcase;

import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;
import cn.schoolwow.util.domain.beanCopy.BeanCopy;
import cn.schoolwow.util.test.module.beanCopy.domain.UserExtend;
import cn.schoolwow.util.test.module.common.domain.User;
import org.junit.Assert;

import java.util.ArrayList;
import java.util.List;

public class CloneObjectListTestCaseFlow implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        List<User> userList = new ArrayList<>();
        for(int i=0;i<10;i++){
            User user = new User();
            user.username = "username"+i;
            user.password = "123456";
            userList.add(user);
        }
        List<UserExtend> userExtendList = BeanCopy.cloneObjectList(userList, UserExtend.class);
        Assert.assertEquals(userList.size(), userExtendList.size());
        for(int i=0;i<userExtendList.size();i++){
            UserExtend userExtend = userExtendList.get(i);
            User user = userList.get(i);

            Assert.assertEquals(userExtend.username, user.username);
            Assert.assertEquals(userExtend.password, user.password);
        }
    }

    @Override
    public String name() {
        return "Bean克隆实例列表测试用例";
    }
}
